﻿using System;

namespace enyo
{
    public class BasicService : Component
    {
        /// <summary>
        /// The name of the service. This information is delegated to the Request component.
        /// </summary>
        public string Service { get; set; }

        /// <summary>
        /// The timeout, specified in milliseconds, after which the service should return a failure condition. If a request times out, the request object will have its didTimeout property set to true. 
        /// A zero value indicates that no timeout will be checked.
        /// </summary>
        public int Timeout { get; set; }

        /// <summary>
        /// Event sent when request returns as successful
        /// <para>function callback(sender, result, request);
        /// </para>
        /// </summary>
        public EnyoEvent<BasicService, object, Request> onSuccess;

        /// <summary>
        /// Event sent when request returns as failure
        /// <para>function callback(sender, result, request);
        /// </para>
        /// </summary>
        public EnyoEvent<BasicService, object, Request> onFailure;

        /// <summary>
        /// Event sent always when request returns, whether successful or not
        /// <para>function callback(sender, result, request);
        /// </summary>
        //TODO:(inSender, inResponse, inRequest)
        public EnyoEvent<BasicService, object, Request> onResponse;

        /// <summary>
        /// Cancels all requests.
        /// </summary>
        public void Cancel()
        {
        }

        /// <summary>
        /// Returns a new service Request component.
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public Request Request(object /*TODO:Option*/options)
        {
            return null;
        }
    }
}
